/**
 * @file otherCmds.c
 * @author MTF-1
 *
 * @date 14-01-2011 DD-MM-YYYY
 * @version 0.3
 *
 * @section DESCRIPTION
 *
 * Module for other commands.
 */

#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include "otherCmds.h"
#include "shell.h"

#define ERROR 1
#define NOERROR 0
#define AMOUNTOFCMD 6

/**
 * Exit program.
 *
 * @author Rik Janssen
 */
int cmdExit()
{
    /*TO DO:
     * - Check if file tranfer is going
     * - Disconnect
     */
    printf("Will now exit...\n");
    exit(0);
}

/**
 * Show program info.
 *
 * @author Rik Janssen
 */
int cmdInfo()
{
    printf("*********************************************\n");
    printf("*             MPNA 3RGK CLIENT              *\n");
    printf("*                                           *\n");
    printf("*Version 0.4 by Robbert Busser & Rik Janssen*\n");
    printf("*********************************************\n");
    return NOERROR;
}

/**
 * Show help.
 *
 * @author Robbert Busser
 */
int cmdHelp(char *ptr_sCmd)
{
    int iCmdNum = -1;

    if(ptr_sCmd)
    {
        getCmdNum(ptr_sCmd, &iCmdNum);

        switch(iCmdNum)
        {
            case 0:
                printf("*****************************\n");
                printf("*     MPNA 3RGK CLIENT      *\n");
                printf("*                           *\n");
                printf("*   Help for command exit   *\n");
                printf("*                           *\n");
                printf("*    Global information:    *\n");
                printf("*  disconnects the current  *\n");
                printf("*   client-server session   *\n");
                printf("*  and closes the program.  *\n");
                printf("*                           *\n");
                printf("*  Technical information:   *\n");
                printf("*  exit without indicator   *\n");
                printf("*****************************\n");
                break;
            case 1:
                printf("*****************************\n");
                printf("*     MPNA 3RGK CLIENT      *\n");
                printf("*                           *\n");
                printf("*  Help for command connect *\n");
                printf("*                           *\n");
                printf("*    Global information:    *\n");
                printf("* creates the client-server *\n");
                printf("*  connection/session with  *\n");
                printf("*       the specificied     *\n");
                printf("*         IPv4 address      *\n");
                printf("*                           *\n");
                printf("*  Technical information:   *\n");
                printf("*  connect with indicator   *\n");
                printf("     your IPv4 address      *\n");
                printf("*****************************\n");
                break;
            case 2:
                printf("*****************************\n");
                printf("*     MPNA 3RGK CLIENT      *\n");
                printf("*                           *\n");
                printf("*Help for command disconnect*\n");
                printf("*                           *\n");
                printf("*    Global information:    *\n");
                printf("*  disconnects the current  *\n");
                printf("*       client-server       *\n");
                printf("*   connection/session      *\n");
                printf("*                           *\n");
                printf("*  Technical information:   *\n");
                printf("*        is coming          *\n");
                printf("*****************************\n");
                break;
            case 3:
                printf("*****************************\n");
                printf("*     MPNA 3RGK CLIENT      *\n");
                printf("*                           *\n");
                printf("*  Help for command info    *\n");
                printf("*                           *\n");
                printf("*    Global information:    *\n");
                printf("*     displays general      *\n");
                printf("*    information about      *\n");
                printf("*  the client program such  *\n");
                printf("*  as version, autor, etc.  *\n");
                printf("*                           *\n");
                printf("*  Technical information:   *\n");
                printf("*  info without indicator   *\n");
                printf("*****************************\n");
                break;
            case 4:
                printf("*****************************\n");
                printf("*     MPNA 3RGK CLIENT      *\n");
                printf("*                           *\n");
                printf("*  Help for command help    *\n");
                printf("*                           *\n");
                printf("*    Global information:    *\n");
                printf("*    displays a list of     *\n");
                printf("* commands were you can get *\n");
                printf("* information about and if  *\n");
                printf("* you need information about*\n");
                printf("* one of those commands you *\n");
                printf("* type that command behind  *\n");
                printf("*   the help command help   *\n");
                printf("*                           *\n");
                printf("*  Technical information:   *\n");
                printf("* For general information:  *\n");
                printf("*  help without indicator   *\n");
                printf("*                           *\n");
                printf("*   For information about   *\n");
                printf("*    one of the commands:   *\n");
                printf("*   help with indicator of  *\n");
                printf("*   the specified command   *\n");
                printf("*****************************\n");
                break;
            case 5:
                printf("*****************************\n");
                printf("*     MPNA 3RGK CLIENT      *\n");
                printf("*                           *\n");
                printf("*  Help for command upload  *\n");
                printf("*                           *\n");
                printf("*    Global information:    *\n");
                printf("* places the specified file *\n");
                printf("*   from the client on the  *\n");
                printf("* specified location on the *\n");
                printf("*          server           *\n");
                printf("*                           *\n");
                printf("*  Technical information:   *\n");
                printf("*    upload with name of    *\n");
                printf("*   the specified file on   *\n");
                printf("*          client           *\n");
                printf("*  and the specified file   *\n");
                printf("*        on server          *\n");
                printf("*****************************\n");
                break;
            default:
                printf("Error when trying to request the function because it does not exist\n");
                return ERROR; /*Unknown command*/
        }
    }
    else
    {
        printf("*****************************\n");
        printf("*     MPNA 3RGK CLIENT      *\n");
        printf("*                           *\n");
        printf("*       Help Function       *\n");
        printf("*       The commands:       *\n");
        printf("*           exit            *\n");
        printf("*          connect          *\n");
        printf("*         disconnect        *\n");
        printf("*           info            *\n");
        printf("*           help            *\n");
        printf("*          upload           *\n");
        printf("*****************************\n");
    }
}
